﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControls_MemberRegistration : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {

        if (MemberInfo.CheckUserEmail(txtEmail.Text) > 0)
        {
            //Response.Write("<script LANGUAGE='JavaScript' >alert('User with the email address: ' " + txtEmail.Text + " 'already exists')</script>");
            //Page.ClientScript.RegisterStartupScript(this.GetType(), "ButtonClickEventScript", "alert('User with the email address: ' " + txtEmail.Text + " 'already exists');", true);
            string message = "User with the email address: ' " + txtEmail.Text + " 'already exists";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("<script type = 'text/javascript'>");
            sb.Append("window.onload=function(){");
            sb.Append("alert('");
            sb.Append(message);
            sb.Append("')};");
            sb.Append("</script>");
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());

            txtEmail.Focus();
        }
        else
        {
            MemberInfo.ExecuteInsert(txtFName.Text, txtLName.Text, ddlGender.SelectedItem.Text, int.Parse(txtAge.Text), txtStreetAddr.Text, ddlProvince.SelectedItem.Text,
                ddlCity.SelectedItem.Text, txtPostal.Text, txtPhone.Text, txtEmail.Text, txtPwd.Text);

            Response.Redirect("Success.aspx");
        }
    }


    protected void TextBox1_TextChanged(object sender, EventArgs e)
    {

    }

    protected void txtEmail_TextChanged(object sender, EventArgs e)
    {

    }
}